package aisLogic;

import java.util.Observable;
import org.w3c.dom.Node;
import org.w3c.dom.Document;
import org.w3c.dom.Element;


public class Module extends Observable implements Cloneable
{
	public static final int TRANS_NONE = 0;
	public static final int TRANS_MIRROR_ROT180 = 1;
	public static final int TRANS_MIRROR = 2;
	public static final int TRANS_ROT180 = 3;
	public static final int TRANS_MIRROR_ROT270 = 4;
	public static final int TRANS_ROT90 = 5;
	public static final int TRANS_ROT270 = 6;
	public static final int TRANS_MIRROR_ROT90 = 7;
	
	public static final int ATT_X = 1;
	public static final int ATT_Y = ATT_X + 1;
	public static final int ATT_WIDTH = ATT_Y + 1;
	public static final int ATT_HEIGHT = ATT_WIDTH + 1;
	public static final int ATT_MISC = ATT_HEIGHT + 1;
	public static final int ATT_FLIP = ATT_MISC + 1;
	public static final int ATT_IMAGE_ID = ATT_FLIP + 1;
	
	
	private int x = 0;
	private int y = 0;
	private int width = 0;
	private int height = 0;
	private int flip = 0;
	private String misc = "";
	private int imageId = 0;

	public Module()
	{
		super();
	}
	
	public Module(int x, int y, int width, int height)
	{
		super();
		this.x = x;
		this.y = y;
		this.width = width;
		this.height = height;
	}
	
	public Module(int x, int y, int width, int height, int flip, String misc, int imageId)
	{
		super();
		this.x = x;
		this.y = y;
		this.width = width;
		this.height = height;
		this.flip = flip;
		this.misc = misc;
		this.imageId = imageId;
	}
	

	public int getFlip()
	{
		return flip;
	}

	public void setFlip(int flip)
	{
		this.flip = (flip > Module.TRANS_ROT90 || flip < Module.TRANS_NONE) ? Module.TRANS_NONE : flip;
		this.setChanged();
		this.notifyObservers();
	}

	public int getHeight()
	{
		return height;
	}

	public void setHeight(int height)
	{
		this.height = height;
	}

	public int getImageId()
	{
		return imageId;
	}

	public void setImageId(int imageId)
	{
		this.imageId = imageId;
	}

	public String getMisc()
	{
		return misc;
	}

	public void setMisc(String misc)
	{
		this.misc = misc;
	}

	public int getWidth()
	{
		return width;
	}

	public void setWidth(int width)
	{
		this.width = width;
	}

	public int getX()
	{
		return x;
	}

	public void setX(int x)
	{
		this.x = x;
	}

	public int getY()
	{
		return y;
	}

	public void setY(int y)
	{
		this.y = y;
	}
	
	
	public Object clone() throws CloneNotSupportedException
	{
		Module m = (Module)super.clone();
		m.x = this.x;
		m.y = this.y;
		m.width = this.width;
		m.height = this.height;
		m.flip = this.flip;
		m.misc = this.misc;
		m.imageId = this.imageId;
		return m;
	}

}
